<?
	$q  = new DBQuery;
	$q->addTable('contacts', 'a');
	$q->addTable('project_contacts', 'b');
	$q->addJoin('departments', 'c', 'a.contact_department = c.dept_id', 'left outer');
	$q->addQuery('a.contact_id, a.contact_first_name, a.contact_last_name,
			a.contact_email, a.contact_phone, c.dept_name');
	$q->addWhere('a.contact_id = b.contact_id and b.project_id = '.$_REQUEST['project_id']);
	$q->addWhere('(contact_owner = '.$AppUI->user_id.' or contact_private = 0)');
	$q->addOrder('c.dept_name, a.contact_first_name');

	$contacts = $q->loadHashList('contact_id');
?>
<table border="0" cellpadding="6" cellspacing="0" width="500px">
<tr>
	<td colspan="5" bgcolor="#E0E0E0"><b><?=$AppUI->_('Project members')?></b></td>
</tr>
<tr bgcolor="#F5F5F5">
	<td width="12" align="center"><img src="images/user.gif"></td>
	<th align="left"><?=$AppUI->_('Name')?></th>
	<th align="left" style="border-left: 1px solid #F0F0F0" width="120px"><img src="images/phone.gif"><?=$AppUI->_('Phone')?></th>
</tr>
<?
$dept = '';
foreach ($contacts as $id => $info) {
	if ($dept != $info['dept_name']) {
		$dept = $info['dept_name'];
?>
<tr>
	<td colspan="3" style="color: #0061A5; border: 1px solid #F0F0F0"><b><?=$dept?></b></td>
</tr>
<?
	}
?>
<tr class="second">
	<td>&nbsp;</td>
	<td nowrap="nowrap">
		<img src="images/mail.gif" title="Send mail"/>&nbsp;<a style="color: black" href="mailto:<?=$info['contact_email']?>"><?=$info['contact_first_name'].' '.$info['contact_last_name'].' &lt;'.$info['contact_email'].'&gt;'?></a>
	</td>
	<td nowrap="nowrap" style="border-left: 1px solid #F0F0F0">
		<?=$info['contact_phone'] ? '<img src="images/phone.gif">'.$info['contact_phone'] : ''?>
	</td>
</tr>
<?	} ?>
</table>
